#include <stdio.h>

void swap(int* a1, int* a2)
{
    int tmp = *a1;
    *a1 = *a2;
    *a2 = tmp;
}

void sort(int* array, int nCnt)
{
    int nPos = 0;
    int nMin = 0;

    for (int i = 0; i < nCnt; i++)
    {
        nMin = array[i];
        nPos = i;
        for (int k = i + 1; k < nCnt; k++)
        {
            if (array[k] < nMin)
            {
                nMin = array[k];
                nPos = k;
            }
        }

        if (i != nPos) 
            swap(&array[i], &array[nPos]);
    }
}

int main()
{
    int array[9] = { 2,8,5,1,3,11,7,2,6 };

    sort(array, sizeof(array) / sizeof(int));

    for (unsigned int i = 0; i < (sizeof(array) / sizeof(int)); ++i)
        printf("%d ", array[i]);
    puts("");

    return 0;
}